<?
include("../lib/config.php");
$nik 	= $HTTP_GET_VARS['nik'];
$op		= $HTTP_GET_VARS['op'];
$no		= $HTTP_GET_VARS['no'];

if($op == "edit"){
	$Faction = "../lib/update.php";
	$Vbutton = "Update";
	$query	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM PengalamanRef WHERE nik='$nik') SELECT * FROM limit WHERE No='$no' ",$conn);
	$row	= mssql_fetch_array($query);
}
else{
	$Faction = "../lib/save.php";
	$Vbutton = "Simpan";
}

include("../header.php");
?>
<script type="text/javascript">
	function LoadFocus(){
		document.forms[0].elements[0].focus();
	}
	
	MaskInput = function(f, m){
	function mask(e){
		var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
			rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
		function accept(c, rule){
			for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
				if(r & i && patterns[i].test(c))
					break;
				return i <= r || c == rule;
		}
		var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
		(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
			r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
			: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
			r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
	}
	for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
		addEvent(f, i, mask);
};

	function Validate(){
		if(document.FEmployee.nik.value == "")
		{
			alert("Field : NIK tidak boleh kosong ...");
			document.FEmployee.nik.focus();
			return false;
		}

		if(document.FEmployee.nama.value == "")
		{
			alert("Field : Nama tidak boleh kosong ...");
			document.FEmployee.nama.focus();
			return false;
		}
		
		if(document.FEmployee.alamat.value == "")
		{
			alert("Field : Alamat tidak boleh kosong ...");
			document.FEmployee.alamat.focus();
			return false;
		}

		if(document.FEmployee.telepon.value == "")
		{
			alert("Field : Telepon tidak boleh kosong ...");
			document.FEmployee.telepon.focus();
			return false;
		}

		if(document.FEmployee.jabatan.value == "")
		{
			alert("Field : Jabatan tidak boleh kosong ...");
			document.FEmployee.jabatan.focus();
			return false;
		}

		if(document.FEmployee.hubungan.value == "")
		{
			alert("Field : Hubungan tidak boleh kosong ...");
			document.FEmployee.hubungan.focus();
			return false;
		}
		
		document.FEmployee.submit();
		
	}
</script>
</head>
<form name="FEmployee" method="post" action="<?=$Faction?>">
<table width="100%">
 <tr>
  <td colspan="2">
	<table width="100%" style="border:none;">
	<tr>
	 <td colspan="2" class="line_bottom">&nbsp;&nbsp;<b>Data Referensi</b></td>
	</tr>
	<tr>
	 <tr>
	  <td>&nbsp;</td>
	 <td align="right" class="line_bottom">
	 <a href="../lib/detailemp.php?show=pribadi&amp;nik=<?=$nik?>">Data Pribadi</a> &raquo; 
	 <a href="../lib/detailemp.php?show=data_umum&amp;nik=<?=$nik?>">Data Umum</a> &raquo; 
	 <a href="../lib/detailemp.php?show=pendidikan&amp;nik=<?=$nik?>">Pendidikan</a> &raquo; 
	 <a href="../lib/detailemp.php?show=kecakapan&amp;nik=<?=$nik?>">Kecakapan</a> &raquo; 
	 <a href="../lib/detailemp.php?show=keluarga&amp;nik=<?=$nik?>">Keluarga</a> &raquo; 
	 <a href="../lib/detailemp.php?show=karir&amp;nik=<?=$nik?>"><b>Pengalaman</b></a> &raquo; 
	 <a href="../lib/detailemp.php?show=organisasi&amp;nik=<?=$nik?>">Organisasi</a> 
	 </td>
	 </tr>
	</table>
  </td>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <!--
 <tr>
  <td><b>NIK</b></td>
  <td>: <input type="text" maxlength="10" value="<?=$nik?>" style="font-weight:bold;" class="text" name="nik"/> <span class="required">*</span></td>
 </tr>
 -->
 <tr>
 <td>
 <table>
 <tr>
  <td>Nama</td>
  <td>: <input type="text" maxlength="50" value="<?=$row[Nama]?>"  class="text" size="50" name="nama"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td valign="top">Alamat</td>
  <td valign="top">&nbsp; <textarea rows="5" cols="35" name="alamat"><?=$row[Alamat]?></textarea><span class="required">*</span></td>
 <tr>
  <td>Telepon</td>
  <td>: <input type="text" maxlength="15" value="<?=$row[NoTelp]?>" size="15"  class="text" name="telepon"/> <span class="required">*</span></td>
 <tr>
  <td>Jabatan</td>
  <td>: <input type="text" maxlength="35" value="<?=$row[Jabatan]?>" size="35" class="text" name="jabatan"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>Hubungan</td>
  <td>: <input type="text" maxlength="35" value="<?=$row[Hubungan]?>" size="35" class="text" name="hubungan"/> <span class="required">*</span></td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td align="left"><br /><br />
  <input type="hidden" name="cat" value="ref_pengalaman" />
  <input type="hidden" name="nik" value="<?=$nik?>" />
  <input type="hidden" name="no" value="<?=$row[No]?>" />
  <input type="reset" value="Batal" onclick="Javascript:history.back();" class="button"/><input type="button" value="<?=$Vbutton?>" class="button" onClick="Validate();" />
  <br /><br />
  </td>
 </tr>
</table>
</form>
<script type="text/javascript">

var f = document.forms[0];
MaskInput(f.telepon,"(99)9999-9999");

//]]>
</script>
</td>
</tr>
<tr>
 <td colspan="2" style="border:none;"><? include("../footer.php"); ?></td>
</tr>
</table>
<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
